import java.util.Scanner;
public class Tihuan{
  public static void main(String[]args){
    Scanner st = new Scanner (System.in);
    int i=0;
    String [] str= new String [100];
    while (st.hasNext()){
      String a=st.nextLine();
      if(a.equals("end"))break;
      str[i]=a;i++;
    }
    String b = st.nextLine();
    String c = st.nextLine();
    for(int j=0;j<i;j++){
      System.out.println(str[j].replace(b,c));
    }
  }
}